package homework.day12;

import java.util.*;

public class Product02 {
    public static void main(String[] args) {
        Set<Product> list= new HashSet<>();
        Product p=new Product(1,"水",45.3,"大连");
        Product p1=new Product(2,"面包",56.3,"苏州");
        Product p2=new Product(3,"泡面",100.3,"上海");
       // Product p3=new Product(4,"香肠",452.3,"杭州");
        Product p4=new Product(5,"啤酒",789.3,"大连");

        list.add(p1);
        list.add(p2);
      //  list.add(p3);
        list.add(p4);
        list.add(p);
        System.out.println(list);
        Product p5=new Product(1,"水",45.3,"大连");
    list.add(p5);
        System.out.println(list);
        Iterator<Product> i =list.iterator();
        while ( i.hasNext()){

            System.out.println(i.next());
        }

        System.out.println("==================================");
        List<Product> list1=new ArrayList<>();
        Iterator<Product> ii =list.iterator();
        while (ii.hasNext()){
            Product pp=ii.next();
            if(pp.getPrice()>300)
                list1.add(pp);
        }
        System.out.println(list1);

    }


}
